﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using University.Workshop.Model;
using University.Workshop.DataAccess;
using System.Globalization;

namespace University.Workshop.Business
{
    public static class PrincipalManager
    {
        public static Information GetAllInfo (String roomName, DateTime date, String state){
            Information info = new Information();
            Client client = new Client();
            Room room = new Room();
            PrincipalDataAccess principalDal = new PrincipalDataAccess();
            principalDal.Dispose();
            RoomDataAccess roomDal = new RoomDataAccess();
            roomDal.Dispose();
            ClientDataAccess clientDal= new ClientDataAccess();
            clientDal.Dispose();

            int ciCLient = principalDal.GetClient(roomName, date, state);
            string clientName= clientDal.GetFullNameFormCI(ciCLient);
            client = new Client {  ClientId= ciCLient.ToString(CultureInfo.CurrentCulture), FullName= clientName};
            int idRoom = roomDal.GetIdRoomByName(roomName);
            int idTypeOfRoom = roomDal.GetTypeOfRoomByName(roomName);
            string typeOfRoom = roomDal.GetTypeById(idTypeOfRoom);
           
            Information infoAuxiliar = principalDal.GetDates(roomName, date, state);
            float serviceCostRoom = 0;
            if (state == "Taken") { serviceCostRoom= RegistrationProduct.GetCost(roomName, infoAuxiliar.CheckIn, infoAuxiliar.Checkout); }
            room = new Room { Id= idRoom, Name= roomName, TypesName = typeOfRoom};
            info = new Information { ClientInfo=client, RoomInfo= room, CheckIn=infoAuxiliar.CheckIn, Checkout= infoAuxiliar.Checkout, State = state, CostSaleProducts=serviceCostRoom };
            return info;
        }
    }
}
